home *** CD-ROM | disk | FTP | other *** search
- property sectiontree
-
- on new me, textsource
- put "Loading database..."
- set sectiontree to [:]
- if listp(textsource) then
- repeat with source in textsource
- load(me, source)
- end repeat
- else
- load(me, textsource)
- end if
- return me
- end
-
- on load me, textsource
- set datadelimiter to "|"
- set mytext to the text of field textsource
- set startTime to the ticks
- set proptext to line 1 of mytext
- set propflatlist to texttolist(proptext, datadelimiter)
- set template to symbol(propflatlist)
- delete line 1 of mytext
- repeat with index = 1 to the number of lines in mytext
- set curline to line index of mytext
- set rec to filltemplate(template, curline, datadelimiter)
- if stringp(rec) then
- alert(rec & ";Error was in line " & index & ".")
- halt()
- end if
- set section to symbol(the section of rec)
- set category to symbol(the category of rec)
- set sectionlist to getaProp(sectiontree, section)
- if voidp(sectionlist) then
- addProp(sectiontree, section, [:])
- set sectionlist to getProp(sectiontree, section)
- end if
- set catlist to getaProp(sectionlist, category)
- if voidp(catlist) then
- addProp(sectionlist, category, [])
- set catlist to getProp(sectionlist, category)
- end if
- append(catlist, rec)
- end repeat
- set endTime to the ticks
- put "interpret:" && endTime - startTime
- end
-
- on loadfiles me
- if isMac() then
- set basepath to the pathName
- delpush(":")
- set basepath to item 1 to the number of items in basepath - 2 of basepath
- delpop()
- set imagepath to basepath & ":images:"
- set videopath to basepath & ":movies:"
- set textpath to basepath & ":text:"
- else
- set imagepath to "..\images\"
- set videopath to "..\movies\"
- set textpath to "..\text\"
- end if
- set data to []
- set imageptr to 140
- set movieptr to 200
- repeat with index = 1 to count(data)
- set rec to getAt(data, index)
- if not voidp(getaProp(rec, #image)) then
- set image to getaProp(rec, #image)
- if image <> EMPTY then
- set imageloc to image
- set pos to offset("\", imageloc)
- repeat while pos > 0
- put ":" into char pos of imageloc
- set pos to offset("\", imageloc)
- end repeat
- put imageloc
- importFileInto(member imageptr, imageloc)
- set imageptr to imageptr + 1
- else
- set imageloc to EMPTY
- end if
- end if
- if not voidp(getaProp(rec, #movie)) then
- set video to getaProp(rec, #movie)
- if video <> EMPTY then
- set videoloc to videopath & video
- put videoloc
- importFileInto(member movieptr, videoloc)
- set movieptr to movieptr + 1
- next repeat
- end if
- set movieloc to EMPTY
- end if
- end repeat
- saveMovie()
- end
-
- on getrecords me, category, section
- set reclist to 0
- if stringp(section) then
- set section to symbol(section)
- end if
- set categorytree to getaProp(sectiontree, section)
- if listp(categorytree) then
- if stringp(category) then
- set category to symbol(category)
- end if
- if category = #all then
- set reclist to []
- repeat with catlist in categorytree
- repeat with rec in catlist
- append(reclist, rec)
- end repeat
- end repeat
- else
- set reclist to getaProp(categorytree, category)
- if not listp(reclist) then
- put "Bad category:" && category
- end if
- end if
- else
- put "Bad section:" && section
- end if
- return reclist
- end
-
- on dispose me
- end
-